// pagesWorkOrder/workOrderMyIndexHandle/workOrderMyIndexHandle.js

const mixin_formItemType = require('../../common/mixins/formItemType')
const {
  SUB_PAGES
} = require('../../config/router.config')

Page({
  behaviors: [mixin_formItemType],

  /**
   * 页面的初始数据
   */
  data: {
    actionValue: {},
    actionSheetList: [{
      label: '处理',
      value: 'handle'
    }, {
      label: '完成',
      value: 'complete'
    }, {
      label: '转交',
      value: 'transfer'
    }, {
      label: '多人协作',
      value: 'cooperation'
    }, {
      label: '工单升级',
      value: 'upgrade'
    }, {
      label: '退单',
      value: 'chargeback'
    }, {
      label: '暂停',
      value: 'pause'
    }, {
      label: '终止',
      value: 'termination'
    }, ],

    handelTime: Date.now(),
    componentId: 'upgrade',
    orderNum: ''
  },
  init() {

  },
  onSelectedActionSheet({
    detail
  }) {
    this.setData({
      componentId: `${detail.value}`
    })
  },
  // 确认
  onFormConfirm() {
    this.selectComponent(`#${this.data.componentId}`).submit(() => {
      wx.redirectTo({
        url: SUB_PAGES.WorkOrder.WORK_ORDER_MY_INDEX.router,
      })
    })
  },


  // 取消
  onFormCancel() {
    wx.navigateBack()
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const {
      orderNum,
      handleState,
      assetName,
      assetAddr
    } = options
    const findVal = this.data.actionSheetList.find(item => item.value == handleState)

    this.setData({
      actionValue: findVal,
      componentId: findVal.value,
      orderNum: orderNum,
      assetName,
      assetAddr

    })


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})